<?php
class Fitness {
	var $workout;
		
	function addWorkout($routine, $workout, $rep1, $weight1, $rep2, $weight2, $weightRequired) {
		//insert validation here
		$query = "INSERT INTO $routine VALUES('','$workout','$rep1','$weight1','$rep2','$weight2','$weightRequired')";
		$result = mysql_query($query) or die('Error: ' . mysql_error());
	}
	
	function listWorkout($routine) {
		//insert validation
		$query = "SELECT workout FROM $routine";
		$result = mysql_query($query) or die('Error: ' . mysql_error());
		$listWorkout = array();
		$i = 0;
		while ($row = mysql_fetch_row($result)){
			$listWorkout[$i] = $row[0];
			$i++;
		}
		return $listWorkout;
	}
	
	function updateWorkout($routine, $workout, $rep1, $weight1, $rep2, $weight2) {
		//insert validation
		$query = "UPDATE $routine SET rep_1='$rep1', weight_1='$weight1', rep_2='$rep2', weight_2='$weight2' WHERE workout='$workout'";
		$result = mysql_query($query) or die('Error: ' . mysql_error());
	}
	
	function fitnessTrackerWelcome($user) {
		if (isset($_SESSION['fName'])) {
			$user = $_SESSION['fName'];
			
			echo nl2br("Welcome $user,
			
			This page is a tracker for your fitness routines.
			You are able to choose from custom made programs or create your own programs.
			Each day it will create statistics about your gains whether it is tonnage or reps.
			
			Stay tuned for more...
			
			Fitness Shack");
		}
	}
}

?>